package com.shopAndMall.AppBuilder.category;

import java.util.List;

import com.shopAndMall.AppBuilder.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class Category0Adapter extends ArrayAdapter<String> {
	Context context;
	List<String> cateNameList;
	Category0DataModel dataModel;
	
	public Category0Adapter(Context context, int textViewResourceId,
			List<String> objects, Category0DataModel dataModel) {
		super(context, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
		
		this.context = context;
		this.cateNameList = objects;
		this.dataModel = dataModel;
	}

	public int getCount() {
		return cateNameList.size();
	}

	public String getItem(int position) {
		return "";
	}

	public View getView(int position, View view, ViewGroup parent) {
		RowWrapper wrapper;
		
		if (view == null) {
			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = inflater.inflate(R.layout.category_row, parent, false);
			wrapper = new RowWrapper(view);
			view.setTag(wrapper);
			
		}else{
			wrapper = (RowWrapper) view.getTag();
		}
	
		wrapper.getCategoryName().setText(cateNameList.get(position));
		
		return view;
	}
	
	
   class RowWrapper{
	   View view;
	   TextView cateName;
	   
	   RowWrapper(View view){
		   this.view = view;
	   }
	   
	   public TextView getCategoryName(){
		   if(cateName == null)
			   cateName = (TextView)view.findViewById(R.id.categoryName);
		   return cateName;
	   }	
   }
	
	
}
